package com.gjy.netty.ag.nio;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-05-17 17:46:40
 */
public class NioServer {

    public static void main(String[] args) throws IOException {

        ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
        serverSocketChannel.bind(new InetSocketAddress("localhost",8000));
        serverSocketChannel.configureBlocking(false);

        Selector selector = Selector.open();
        new Thread(new ReactorTask()).start();

        SelectionKey key = serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);

    }
}
